﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DAL;
using DomainModel;

namespace BL
{
  public static class BLStudent
  {
    public static void InsertStudent(Tv student, ref List<string> errors)
    {
      if (student == null)
      {
        errors.Add("Student cannot be null");
        return;
      }

      if (student.id.Length < 5)
      {
        errors.Add("Invalid student ID");
        return;
      }

      if (errors.Count > 0)
        return;

      DALStudent.InsertStudent(student, ref errors);
    }

    public static Tv GetStudent(string id, ref List<string> errors)
    {
      if (id == null)
      {
        errors.Add("Invalid student ID");
        return null;
      }

      // anything else to validate?

      if (errors.Count > 0)
        return null;

      return (DALStudent.GetStudentDetail(id, ref errors));
    }

    public static void DeleteStudent(string id, ref List<string> errors)
    {
      if (id == null)
      {
        errors.Add("Invalid student ID");
        return;
      }

      if (errors.Count > 0)
        return;

      DALStudent.DeleteStudent(id, ref errors);
    }

    public static List<Tv> GetStudentList(ref List<string> errors)
    {
      return DALStudent.GetStudentList(ref errors);
    }
  }
}
